<template>
 <div>
      <van-nav-bar
        title="添加新地址"
        left-text="返回"
        left-arrow
        @click-left="$router.back()"
        />
    <van-address-edit
        :area-list="areaList"
        show-postal
        show-delete
        show-set-default
        show-search-result
        :search-result="searchResult"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
        @change-detail="onChangeDetail"
    />
</div>
</template>
<script>
import areaList from "../assets/area.js";
import Vue from "vue";
import { Toast } from "vant";
import { parse } from "qs";
Vue.use(Toast);
export default {
  data() {
    return {
      areaList,
      searchResult: []
    };
  },
  methods: {
    onSave(content) {
      Toast("添加成功！");
      this.$store.commit("AddAddress", content);
      this.$router.push(`/address`);
      //  console.log( JSON.parse("false"))
    },
    onDelete() {
      Toast("delete");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "金銮国际大厦一期19楼",
            address: "深圳市龙华区"
          }
        ];
      } else {
        this.searchResult = [];
      }
    }
  }
};
</script>
<style scoped>
</style>

